-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PHP 8 string offset warnings in getColumnName and addIndex #132
base: master
Are you sure you want to change the base?
Conversation
- Updated getColumnName method to handle cases where an empty array is passed, setting the fieldName to null to avoid PHP 8 string offset warnings. - Modified addIndex method to ensure 'fields' are always treated as an array, preventing potential issues with non-array types. - Added checks in both methods to ensure compatibility with PHP 8 while maintaining backward compatibility with older PHP versions. These changes resolve the PHP 8 warnings related to string offsets in the Table class of the Doctrine integration within our Symfony project.
Hello @saracubillas, Welcome and thank for your contribution. It looks indeed fix a wrong value type. I am curious about the case where the issue you want to solve appears. Some questions.
To be able to reproduce it. Can you share an example of Doctrine integration within Symfony project ? |
hi @alquerci !
Yes, the issue is related to the YAML schema configuration. The task sfDoctrineBuildModelTask reads the schema that configuration to generate the model classes. The way single-column and multi-column indexes are defined in schema.yml is directly influencing how the corresponding PHP code is generated.
It's not directly a "default setting" of Symfony1, the behavior is a result of how the Symfony1 Doctrine plugin interprets and processes the YAML schema configurations.
Example of Doctrine Integration within a Symfony Project:
execute the $this->index(' product_name_index', array( $this->index('order_product_customer_index', array( |
# schema.yml
Product:
columns:
id:
type: integer
primary: true
autoincrement: true
product_id:
type: integer
customer_id:
type: integer
indexes:
# change break this
single_field_index:
fields: product_id
multi_field_index:
fields:
- product_id
- customer_id
# the change make this kind of index without PHP warning
empty_composite_foreign_key_index:
fields:
- []
composite_foreign_key_index:
fields:
- ['customer_id'] What kind of index configuration match the issue? |
single_field_index: |
Yes, you answered to my question. |
I added test for your use case. They failed, without surprise. See #133 Do you have this following PHP warning?
|
the first warning was my problem. The Fatal I did not have it |
These changes resolve the PHP 8 warnings related to string offsets in the Table class of the Doctrine integration within our Symfony project.